﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DAO
{
    public static class UserManagement
    {
        public static Dictionary<long, bool> loggedUsers = new Dictionary<long, bool>();

        public static void AddUserToList(long userid, bool logged)
        {
            loggedUsers.Add(userid, logged);
        }

        public static void RemoveUserFromList(long userid)
        {

        }

        public static void setUserLogged(long userid, bool logged)
        {
            bool user;
            if (loggedUsers.TryGetValue(userid, out user))
            {
                loggedUsers[userid] = logged;
            }
            else AddUserToList(userid, logged);
        }

        public static bool getUserStatus(long userid)
        {
            bool user;
            if (loggedUsers.TryGetValue(userid, out user))
            {
                return loggedUsers[userid];
            }
            else AddUserToList(userid, false);
            return loggedUsers[userid];
        }

        public static int getNumberLoggedUsers()
        {
            int loggedusers = 0;
            foreach (KeyValuePair<long, bool> kv in loggedUsers)
            {
                if (kv.Value == true) loggedusers++;
            }
            return loggedusers;
        }
    }
}
